<template>
  <div>
    <van-form class="upload-box">
      <van-field type="textarea" class="text-input" v-model="txt" label="待校验文本"></van-field>
    </van-form>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'

@Component
export default class TextInput extends Vue {
  get txt () {
    return this.$store.state.api.content
  }

  set txt (v: string) {
    v = v.replaceAll(/[\r\n]/g, '')
    if (v === '') {
      this.$emit('dataOk', false)
    } else if (this.$store.state.api.content === '') {
      this.$emit('dataOk', true)
    }
    this.$store.state.api.content = v
  }

  mounted () {
    this.$store.state.api.content = ''
  }
}
</script>

<style scoped lang="less">
@import "common";
.upload-box {
  .text-input {
    font-size: 1rem;
    ::v-deep .van-field__control {
      border-bottom: 1px solid #ebedf0;
      min-height: 5rem;
    }
  }
}
</style>
